﻿@model MvcForum.Web.ViewModels.Admin.DeleteCategoryViewModel
@{
    ViewBag.Title = "Delete Category";
    var topicCount = Model.Category.Topics.Count;
}

@Html.Partial("_CategoryNavButtons")

<div class="panel">
    <div class="panel-heading">
        <h5>@ViewBag.Title</h5>
    </div>
    <div class="panel-content">
        @if (Model.SubCategories.Any())
        {
            <h2>Unable To Delete</h2>
            <p>This category has sub categories, please re-assign them to new parent categories first</p>

            <h4>Sub Categories</h4>
            <ul>
                @foreach (var subCat in Model.SubCategories)
                {
                    <li><strong>@subCat.Name</strong></li>
                }
            </ul>

            <a href="@Url.Action("Index")" class="btn-mvc btn-mvc-large">Back</a>
        }
        else if (Model.Category.Topics.Any())
        {
            <h2>Unable To Delete</h2>
            <p>This category has discussions associated with it, please either delete or move the topics to a different category</p>

            <h4>Topics</h4>
            <ul>
                @foreach (var topic in Model.Category.Topics.Take(10))
                {
                    <li><a href="@topic.NiceUrl">@topic.Name</a></li>
                }
            </ul>
            if (topicCount > 10)
            {
                <p>And @(topicCount - 10) other topics...</p>
            }
            <a href="@Url.Action("Index")" class="btn-mvc btn-mvc-large">Back</a>
        }
        else
        {
            using (Html.BeginForm("DeleteCategory", "AdminCategory", FormMethod.Post))
            {
                <h2>Delete Category?</h2>
                <p>Are you sure you want to delete this Category? You cannot undo this action.</p>
                @Html.HiddenFor(x => x.Id)
                <div class="submit-holder">
                    <input type="submit" class="btn-mvc btn-mvc-large" value="Yes" />
                </div>
            }
        }
    </div>
</div>

